$msbuild = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
$project = Get-Project
$projectFolder = Split-Path -Parent -Path $project.FullName
$nuget =$($projectFolder + "\..\.nuget\NuGet.exe")

$targets = @(
	 @{name="3.5";parameter=""},
	 @{name="4.0";parameter=""},
	 @{name="4.5";parameter=";Package"})

# Make sure the nuget executable is writable
Set-ItemProperty $nuget -Name IsReadOnly -Value $false

Write-Host "Updating NuGet..." -ForegroundColor DarkGreen
Write-Host (Invoke-Command -ScriptBlock {&$nuget update -Self} -ErrorAction Stop)
Write-Host ""

foreach($target in $targets)
{

	Write-Host "Building target: "$target.name

	Start-Process $msbuild (".\TypeScriptProxyGenerator.csproj /t:Build" + $target.parameter + " /p:Configuration=`"Release " +$target.name + "`"") -Wait -PassThru -NoNewWindow | Out-Null

	Write-Host "-------------------------------------------"

}

Write-Host ""

Get-ChildItem -Path $("$projectFolder\Nuget Output\") | `
 Select-Object FullName | `
 %{ Write-Host $project.ProjectItems.AddFromFile($_.FullName).Name " added to project"}

Write-Host ""
Write-Host "Done!" -ForegroundColor DarkGreen
#Write-Host "Press any key to continue ..."
#$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")